<template>
    <div class="flex flex_column" style="height: 100% ;">
        <div class="flex justify_center align_center" v-if="showSpin" style="width: 100vw;height: 100vh;position: fixed;top: 0;left: 0;z-index: 999;background: rgba(0, 0, 0, .4);">
            <a-spin dot :size="16" />
        </div>
        <div class="flex" style="margin-bottom: 16px">
            <a-tooltip content="请输入箱号">
                <a-input v-model="objectData.box" placeholder="请输入箱号" allow-clear style="width:calc((100% - 64px) / 6);margin-right:16px;" />
            </a-tooltip>
            <a-tooltip content="请输入车号">
                <a-input v-model="objectData.car_no" placeholder="请输入车号" allow-clear style="width:calc((100% - 64px) / 6);margin-right:16px;" />
            </a-tooltip>
            <div class="flex" style="width:calc((100% - 64px) / 6);">
                <a-button type="primary" style="margin-right:16px;" @click="handleSouSuo(1)">搜索</a-button>
                <a-button @click="handleChongZhi(1)">重置</a-button>
            </div>
        </div>
        <div class="flex_1 flex">
            <div class="" style="width: 60%;">
                <!-- `https://ec.95306.cn/goPdf?aqcnsfileId=${itemDatas.ec_id}` -->
                 <!-- https://ec.95306.cn/previewPdf?ywid=TYFJV0011570&queryType=DZYD&pdfApiMap=HP -->
                  <!-- https://ec.95306.cn/previewPdf?ywid=${itemDatas.ticket_number}&queryType=DZYD&pdfApiMap=HP -->
                   <div style="overflow-y: auto;height:800px">
                        <div v-for="(item,index) in itemData.pdf_url" :key="index" >
                            <a-spin :loading="daShpwloading" tip="请稍等..." dot  style="width:100%" >
                                <iframe :src="item + '#zoom=100'" frameborder="0" width="100%" height="800px"></iframe>
                            </a-spin>
                        </div>
                   </div>
                
                
                
            </div>
            <div class="flex_1 flex flex_column" style="margin-left: 16px;height: 100%;">
                <div style="font-size: 18px;font-weight: 600;color: rgba(0, 0, 0, .6);margin-bottom: 16px;">基础信息</div>
                <div class="flex flex_wrap" style="margin-bottom: 16px;">
                    <div class="jcBox flex align_center">
                        <div class="flex justify_end" style="width: 100px;">
                            <div>运输方式：</div>
                        </div>
                        <div class="flex_1" style="overflow: hidden;">
                            <a-select v-model="itemData.transport_type" :options="props.yunshuList" :field-names="{ value: 'key', label: 'title' }" :style="{width:'100%'}"
                            allow-clear allow-search placeholder="请选择运输方式" />
                        </div>
                    </div>
                    <div class="jcBox flex align_center">
                        <div class="flex justify_end" style="width: 100px;">
                            <div>车号：</div>
                        </div>
                        <a-input v-model="itemData.car_no" :style="{flex:1}" placeholder="请输入车种" allow-clear />
                    </div>
                    <div class="jcBox flex align_center">
                        <div class="flex justify_end" style="width: 100px;">
                            <div style="color: red;" v-if="itemData.transport_type == 2">*</div>
                            <div>车种：</div>
                        </div>
                        <a-auto-complete v-model="itemData.car_type" :data="carTypeData" @blur="carTypeSaveHistory" @search="handleCarTypeSearch" :style="{flex:1}" placeholder="请输入车种"/>
                        <!-- <a-input v-model="itemData.car_type" :style="{flex:1}" placeholder="请输入车种" allow-clear /> -->
                    </div>
                    <div class="jcBox flex align_center">
                        <div class="flex justify_end" style="width: 100px;"> 
                            <div style="color: red;">*</div>
                            <div>发站：</div>
                        </div>
                        <div class="flex_1" style="overflow: hidden;">
                            <a-select v-model="itemData.sending_station" :options="sendList" :filter-option="filterOption" :field-names="{ value: 'id', label: 'name' }" :style="{width:'100%'}"
                            allow-clear allow-search placeholder="车站：" @change="handleSendChange($event,1)" />
                        </div>
                        <div class="flex_1" style="overflow: hidden;">
                            <a-select v-model="itemData.sending_tlj" :options="sendJuList" :field-names="{ value: 'id', label: 'name' }" :style="{width:'100%'}"
                            allow-clear allow-search placeholder="到/发局" />
                        </div>
                    </div>
                    <div class="jcBox flex align_center">
                        <div class="flex justify_end" style="width: 100px;">
                            <div style="color: red;">*</div>
                            <div>发站专用线：</div>
                        </div>
                        <a-input v-model="itemData.sending_station_special" :style="{flex:1}" placeholder="请输入发站专用线" allow-clear />
                    </div>
                    <div class="jcBox flex align_center">
                        <div class="flex justify_end" style="width: 100px;">
                            <div style="color: red;">*</div>
                            <div>托运人：</div>
                        </div>
                        <!-- <a-input v-model="itemData.shipper" :style="{flex:1}" placeholder="请输入托运人" allow-clear /> -->
                        <a-auto-complete v-model="itemData.shipper" :data="tuoyunData" @blur="tuoyunSaveHistory" @search="handleTuoyunSearch" :style="{flex:1}" placeholder="请输入托运人"/>
                    </div>
                    <div class="jcBox flex align_center">
                        <div class="flex justify_end" style="width: 100px;">
                            <div>托运经办人：</div>
                        </div>
                        <a-auto-complete v-model="itemData.shipper_agent" :data="tuoyunUserData" @blur="tuoyunUserSaveHistory" @search="handleTuoyunUserSearch" :style="{flex:1}" placeholder="请输入托运经办人"/>
                        <!-- <a-input v-model="itemData.shipper_agent" :style="{flex:1}" placeholder="请输入托运经办人" allow-clear /> -->
                    </div>
                    <div class="jcBox flex align_center">
                        <div class="flex justify_end" style="width: 100px;">
                            <div>托运电话：</div>
                        </div>
                        <a-auto-complete v-model="itemData.shipper_phone" :data="tuoyunPhoneData" @blur="tuoyunPhoneSaveHistory" @search="handleTuoyunPhoneSearch" :style="{flex:1}" placeholder="请输入托运电话"/>
                        <!-- <a-input v-model="itemData.shipper_phone" :style="{flex:1}" placeholder="请输入托运电话" allow-clear /> -->
                    </div>
                    <div class="jcBox flex align_center">
                        <div class="flex justify_end" style="width: 100px;">
                            <div style="color: red;">*</div>
                            <div>到站：</div>
                        </div>
                        <div class="flex_1" style="overflow: hidden;">
                            <a-select v-model="itemData.come_address" :options="sendList" :filter-option="filterOption" :field-names="{ value: 'id', label: 'name' }" :style="{width:'100%'}"
                            allow-clear allow-search placeholder="车站：" @change="handleSendChange($event,2)" />
                        </div>
                        <div class="flex_1" style="overflow: hidden;">
                            <a-select v-model="itemData.come_tlj" :options="arriveJuList" :field-names="{ value: 'id', label: 'name' }" :style="{width:'100%'}"
                            allow-clear allow-search placeholder="到/发局" />
                        </div>
                    </div>
                    <div class="jcBox flex align_center">
                        <div class="flex justify_end" style="width: 100px;">
                            <div style="color: red;">*</div>
                            <div>到站专用线：</div>
                        </div>
                        <a-input v-model="itemData.arrive_station_special" :style="{flex:1}" placeholder="请输入到站专用线" allow-clear />
                    </div>
                    <div class="jcBox flex align_center">
                        <div class="flex justify_end" style="width: 100px;">
                            <div>客户：</div>
                        </div>
                        <div class="flex_1" style="overflow: hidden;">
                            <a-select :disabled="is_nobody" v-model="itemData.dept_id" :options="dept_list" :filter-option="filterOption" :field-names="{ value: 'id', label: 'name' }" :style="{width:'100%'}"
                            allow-clear allow-search placeholder="请选择客户" @change="handleChangeDept" />
                        </div>
                        <div style="overflow: hidden; margin-left:10px; ">
                            <a-button type="primary" shape="circle"  @click="openAdd">
                                <icon-plus />
                            </a-button>
                            <!-- <a-button type="primary" @click="openAdd">新增客户</a-button> -->
                        </div>
                    </div>
                    <div class="jcBox flex align_center">
                        <div class="flex justify_end" style="width: 100px;">
                            <!-- <div style="color: red;">*</div>
                            <div>：</div> -->
                        </div>
                        <a-checkbox v-model="is_nobody" @change="isNobodyChange">无主货</a-checkbox>
                    </div>
                    <div class="jcBox flex align_center">
                        <div class="flex justify_end" style="width: 100px;">
                            <div>服务方式：</div>
                        </div>
                        <div class="flex_1" style="overflow: hidden;">
                            <a-select  :disabled="is_nobody" v-model="itemData.service_type" :options="serviceList" :field-names="{ value: 'key', label: 'title' }" :style="{width:'100%'}"
                            allow-clear allow-search placeholder="请选择服务方式" />
                        </div>
                    </div>
                    <div class="jcBox flex align_center">
                        <div class="flex justify_end" style="width: 100px;">
                            <div>合同：</div>
                        </div>
                        <div class="flex_1" style="overflow: hidden;">
                            <a-select  :disabled="is_nobody" v-model="itemData.contract_id" :options="contractList" :field-names="{ value: 'id', label: 'name' }" :style="{width:'100%'}"
                            allow-clear allow-search placeholder="请选择合同" @change="handlechangeadderr" />
                        </div>
                        <div style="overflow: hidden; margin-left:10px; ">
                            <a-button type="primary" shape="circle"  @click="saveHt">
                                <icon-plus />
                            </a-button>
                            <!-- <a-button type="primary" @click="saveHt">新增合同</a-button> -->
                        </div>
                    </div>
                    <div class="jcBox flex align_center">
                        <div class="flex justify_end" style="width: 100px;">
                            <div>客户经办人：</div>
                        </div>
                        <a-auto-complete v-model="itemData.customer_handler" :data="kehuUserData" @blur="kehuUserSaveHistory" @search="handleKehuUserSearch" :style="{flex:1}" placeholder="请输入客户经办人"/>
                        <!-- <a-input  :disabled="is_nobody" v-model="itemData.customer_handler" :style="{flex:1}" placeholder="请输入客户经办人" allow-clear /> -->
                    </div>
                    <div class="jcBox flex align_center">
                        <div class="flex justify_end" style="width: 100px;">
                            <div v-if="!is_nobody" style="color: red;">*</div>
                            <div>客户电话：</div>
                        </div>
                        <a-input  :disabled="is_nobody" v-model="itemData.customer_tel" :style="{flex:1}" placeholder="请输入客户电话" allow-clear />
                    </div>
                    <div class="jcBox flex align_center">
                        <div class="flex justify_end" style="width: 100px;">
                            <div v-if="!is_nobody" style="color: red;">*</div>
                            <div>通知时间：</div>
                        </div>
                        <a-date-picker
                            style="flex:1"
                             :disabled="is_nobody"
                            v-model="itemData.notice_time"
                            show-time
                            format="YYYY-MM-DD HH:mm"
                        />
                    </div>
                    <div class="jcBox flex align_center" v-if="itemData.service_type == 2 || itemData.service_type == 4">
                        <div class="flex justify_end" style="width: 100px;">
                            <div v-if="!is_nobody" style="color: red;">*</div>
                            <div>送货电话：</div>
                        </div>
                        <a-input  :disabled="is_nobody" v-model="itemData.shipping_tel" :style="{flex:1}" placeholder="请输入送货电话" allow-clear />
                    </div>
                    <!-- <div class="jcBox flex align_center">
                        <div class="flex justify_end" style="width: 100px;">
                            <div>是否仓储：</div>
                        </div>
                        <div class="flex_1" style="overflow: hidden;">
                            <a-select v-model="itemData.serve_type" :options="props.fuwuList" :field-names="{ value: 'key', label: 'title' }" :style="{width:'100%'}"
                            allow-clear allow-search placeholder="请选择是否仓储" />
                        </div>
                    </div> -->
                    <div class=" flex_1 flex align_center" style="margin-bottom: 12px;" v-if="itemData.service_type == 2 || itemData.service_type == 4">
                        <div class="flex justify_end" style="width: 100px;">
                            <div>送货地址：</div>
                        </div>
                        <div class="flex_1" style="overflow: hidden;">
                            <a-select  :disabled="is_nobody" v-model="itemData.shipping_address" :options="peisongaddrrList" :field-names="{ value: 'id', label: 'address' }" :style="{width:'100%'}"
                            allow-clear allow-search placeholder="请选择送货地址" />
                        </div>
                        
                    </div>
                </div>
                <div style="font-size: 18px;font-weight: 600;color: rgba(0, 0, 0, .6);margin-bottom: 16px;">品名</div>
                <div class=" scllBox" style="margin-bottom: 16px;max-height: 270px;">
                    <div class="flex scllItem" v-for="(item,index) in itemData.goods_data" :key="index" style="border-bottom: 1px solid rgba(0, 0, 0, .15);">
                        <div class="flex_1 flex flex_wrap">
                            <div class="jcBox flex align_center">
                                <div class="flex justify_end" style="width: 100px;">
                                    <div>原票号：</div>
                                </div>
                                <a-input v-model="item.ticket_number" :style="{flex:1}" placeholder="请输入原票号" allow-clear />
                            </div>
                            <div class="jcBox flex align_center">
                                <div class="flex justify_end" style="width: 100px;">
                                    <div>品名：</div>
                                </div>
                                <div class="flex_1" style="overflow: hidden;">
                                    <a-select v-model="item.goods_id" :options="props.goods_list" :filter-option="filterOption" :field-names="{ value: 'id', label: 'name' }" style="width:100%"
                                    allow-clear allow-search placeholder="请选择品名" @change="handleChangeGood" :disabled="index == 0?false:true" />
                                </div>
                            </div>
                            <div class="jcBox flex align_center">
                                <div class="flex justify_end" style="width: 100px;">
                                    <div>包装：</div>
                                </div>
                                <a-auto-complete v-model="item.baozhuang" :data="baozhuangData" @blur="baozhuangSaveHistory(index)" @search="handleBaozhuangSearch" :style="{flex:1}" placeholder="请输入包装"/>
                                <!-- <a-input v-model="item.baozhuang" :style="{flex:1}" placeholder="请输入包装" allow-clear /> -->
                            </div>
                            <div class="jcBox flex align_center" v-if="itemData.transport_type == 1">
                                <div class="flex justify_end" style="width: 100px;">
                                    <div>箱号：</div>
                                </div>
                                <a-input v-model="item.box" :style="{flex:1}" placeholder="请输入箱号" allow-clear />
                            </div>
                            <div class="jcBox flex align_center" v-if="itemData.transport_type == 1">
                                <div class="flex justify_end" style="width: 100px;">
                                    <div>箱型箱类：</div>
                                </div>
                                <div class="flex_1" style="overflow: hidden;">
                                    <a-select v-model="item.box_type_id" :options="boxTypeList" :field-names="{ value: 'id', label: 'name' }" style="width:100%"
                                    allow-clear allow-search placeholder="请选择类型" @change="handleChangeBoxType($event,index)" />
                                </div>
                            </div>
                            <div class="jcBox flex align_center" v-if="itemData.transport_type == 1">
                                <div class="flex justify_end" style="width: 100px;">
                                    <div>箱属：</div>
                                </div>
                                <div class="flex_1" style="overflow: hidden;">
                                    <a-select v-model="item.box_belong"  @change="handleChangeBoxBelong" :options="box_belongList" :field-names="{ value: 'key', label: 'title' }" style="width:100%"
                                        allow-clear allow-search placeholder="请选择箱属" />
                                </div>
                            </div>
                            <div class="jcBox flex align_center" v-if="itemData.transport_type == 1">
                                <div class="flex justify_end" style="width: 100px;">
                                    <div>空重状态：</div>
                                </div>
                                <div class="flex_1" style="overflow: hidden;">
                                    <a-select v-model="item.is_empty" :options="is_emptyList" :field-names="{ value: 'key', label: 'title' }" style="width:100%"
                                    allow-clear allow-search placeholder="请选择空/重状态" />
                                </div>
                            </div>
                            <div class="jcBox flex align_center">
                                <div class="flex justify_end" style="width: 100px;">
                                    <div>件数：</div>
                                </div>
                                <a-input v-model="item.number_yu" :style="{flex:1}" placeholder="请输入件数" allow-clear />
                            </div>
                            <div class="jcBox flex align_center">
                                <div class="flex justify_end" style="width: 100px;">
                                    <div>货重：</div>
                                </div>
                                <a-input v-model="item.hz_weight" :style="{flex:1}" placeholder="请输入货重" allow-clear />
                            </div>
                            <div class="jcBox flex align_center">
                                <div class="flex justify_end" style="width: 100px;">
                                    <div>承运人重量：</div>
                                </div>
                                <a-input v-model="item.cyr_weight" :style="{flex:1}" placeholder="请输入承运人重量" allow-clear />
                            </div>
                            <div class="jcBox flex align_center">
                                <div class="flex justify_end" style="width: 100px;">
                                    <div>标重：</div>
                                </div>
                                <a-input v-model="item.bz_weight" :style="{flex:1}" placeholder="请输入标重" allow-clear />
                            </div>
                            <div class="jcBox flex align_center">
                                <div class="flex justify_end" style="width: 100px;">
                                    <div>计费重量：</div>
                                </div>
                                <a-input v-model="item.jf_weight" :style="{flex:1}" placeholder="请输入计费重量" allow-clear />
                            </div>
                        </div>
                        <div class="flex align_center" style="margin-left: 12px;"><a-link @click="handleDel(index)" v-if="itemData.transport_type == 1 && index != 0 ">删除</a-link></div>
                    </div>
                </div>
                <div style="" @click="handleAdd" v-if="itemData.transport_type == 1"><a-link><icon-plus /> 添加</a-link></div>
                <div class="flex justify_end" style="align-items:center;">
                    <div style="font-size:16px;">第{{(center+1)}}条</div>
                    <div style="font-size:16px;"> / </div>
                    <div style="margin-right: 20px;font-size:16px;">共{{chongGouList.length}}条</div>
                   
                    <a-button type="primary" style="margin-right: 12px;" @click="handlePre">上一单</a-button>
                    <a-button type="primary" style="margin-right: 12px;" @click="handleNext">下一单</a-button>
                    <a-button type="primary" style="margin-right: 12px;" @click="handleBaoCun(2)">提交并生成账单</a-button>
                    <a-button type="primary" @click="handleBaoCun(1)">保存</a-button>
                </div>
            </div>
        </div>
        <!-- 确认账单 -->
        <a-modal :mask-closable="false"  v-model:visible="showBill" title="确认账单" @cancel="showBill = false" :width="1400" :footer="false">
            <bill ref="billRef" v-if="showBill" :item="billData" :type="2" @quxiao="showBill = false" @shuaxin="zhangdanshuaxin" ></bill>
        </a-modal>


        


        <!-- 新增/编辑 -->
        <a-modal :mask-closable="false"  v-model:visible="visible_Add" :width="1080" @cancel="visible_Add=false" :on-before-ok="handleAddOk">
            <template #title>
                新增
            </template>
            <div class="contenBox" style="overflow: auto;">
            <div style="margin-bottom: 16px">
                <a-card  :header-style="{background:'#f5f5f5',color:'rgba(0, 82, 217, 1)',fontWeight:'600'}">
                <template #title>
                    <div style="color:rgba(0, 82, 217, 1);font-weight:600">基本信息</div>
                </template>
                <div class="flex marbot24 align_center" style="width:100%" >
                    <div class="flex align_center" style="margin-right:36px;width:calc((100% - 72px) / 3);">
                    <div class="font14 ">类型：</div>
                    <div class="flex align_center" style="height:32px">
                        <a-space size="large">
                        <a-radio-group v-model="addItem.type" :options="typeList" @change="handleType" />
                        </a-space>
                    </div>
                    </div>
                    <div  class="flex align_center" style="margin-right:36px;width:calc((100% - 72px) / 3);">
                    <div  class="font14 ">客户类型：</div>
                    <div class="flex align_center" style="height:32px">
                        <a-space size="large">
                        <a-radio-group v-model="addItem.customer_type" :options="customerTypeList" />
                        </a-space>
                    </div>
                    </div>
                    <div class="flex align_center" style="margin-right:36px;width:calc((100% - 72px) / 3);">
                    <div class="font14 ">状态：</div>
                    <div class="flex align_center" style="height:32px">
                        <a-space size="large">
                        <a-radio-group v-model="addItem.status" :options="statusList" />
                        </a-space>
                    </div>
                    </div>
                </div>
                <div class="flex marbot24 align_center" style="width:100%" v-if="addItem.customer_type == 1">
                    <div  style="margin-right:36px;width:calc((100% - 72px) / 3);">
                    <div class="font14 marbot4 flex align_center"><div style="color: red;">*</div>客户名称：</div>
                    <a-select style="flex:1" :loading="loading" placeholder="请选择客户名称" v-model="addItem.name"
                                @search="handleSearch" :filter-option="false" @change='handleYinhanInfo($event)'  allow-search >
                        <a-option v-for="item of deptSearchList" :value="item.creditNo" >{{item.companyName}}</a-option>
                    </a-select>
                    <!-- <a-input v-model="addItem.name" placeholder="请输入客户名称" allow-clear @change="handleKehuInfo" /> -->
                    </div>
                    <div style="width:calc((100% - 72px) / 3);margin-right:36px;">
                    <div class="font14 marbot4">负责人:</div>
                    <a-input v-model="addItem.leader" placeholder="请输入负责人" allow-clear  />
                    </div>
                    <div style="width:calc((100% - 72px) / 3);">
                    <div class="font14 marbot4 flex align_center"><div style="color: red;">*</div>联系电话:</div>
                    <a-input v-model="addItem.phone" placeholder="请输入联系电话" allow-clear  />
                    </div>
                </div>
                <div class="flex marbot24" style="width:100%" v-if="addItem.customer_type == 1">
                    <div style="margin-right:36px;width:calc((100% - 72px) / 3);">
                    <div class="font14 marbot4">邮箱:</div>
                    <a-input v-model="addItem.e_mail" placeholder="请输入邮箱" allow-clear  />
                    </div>
                    <div style="width:calc((100% - 72px) / 3);margin-right:36px;">
                    <div class="font14 marbot4">纳税人识别号:</div>
                    <a-input v-model="addItem.card_id" placeholder="请输入纳税人识别号" allow-clear  />
                    </div>
                    <div style="width:calc((100% - 72px) / 3);">
                    <div class="font14 marbot4">标签组:</div>
                    <a-select v-model="addItem.tag_ids"  placeholder="请选择标签" multiple>
                        <a-option v-for="item of tagList" :value="item.id" :label="item.name" />
                    </a-select>
                    </div>
                </div>
                <div class="flex marbot24 align_center" style="width:100%" v-if="addItem.customer_type == 2">
                    <div  style="margin-right:36px;width:calc((100% - 72px) / 3);">
                    <div class="font14 marbot4">客户名称：</div>
                    <a-input v-model="addItem.name" placeholder="请输入客户名称" allow-clear  />
                    </div>
                    <div style="width:calc((100% - 72px) / 3);margin-right:36px;">
                    <div class="font14 marbot4">联系电话:</div>
                    <a-input v-model="addItem.phone" placeholder="请输入联系电话" allow-clear  />
                    </div>
                    <div style="width:calc((100% - 72px) / 3);">
                    <div class="font14 marbot4">邮箱:</div>
                    <a-input v-model="addItem.e_mail" placeholder="请输入邮箱" allow-clear  />
                    </div>
                </div>
                <div class="flex marbot24" style="width:100%" v-if="addItem.customer_type == 2">
                    <div style="width:calc((100% - 72px) / 3);margin-right:36px;">
                    <div class="font14 marbot4">身份证号:</div>
                    <a-input v-model="addItem.card_id" placeholder="请输入身份证号" allow-clear  />
                    </div>
                    <div style="width:calc((100% - 72px) / 3);">
                    <div class="font14 marbot4">标签组:</div>
                    <a-select v-model="addItem.tag_ids"  placeholder="请选择标签" multiple>
                        <a-option v-for="item of tagList" :value="item.id" :label="item.name" />
                    </a-select>
                    </div>
                </div>
                <div class="flex marbot24" style="width:100%">
                    <div style="width:100%;">
                    <div class="font14 marbot4">营业执照：</div>
                    <ma-upload v-model="addItem.file" type='image' />
                    </div>
                </div>
                <div class="flex marbot24" style="width:100%">
                    <div style="width:100%;">
                    <div class="font14 marbot4">备注:</div>
                    <a-textarea placeholder="请输入备注" v-model="addItem.remark" allow-clear/>
                    </div>
                </div>
                </a-card>
            </div>
            <div style="margin-bottom: 16px">
                <a-card  :header-style="{background:'#f5f5f5',color:'rgba(0, 82, 217, 1)',fontWeight:'600'}">
                <template #title>
                    <div style="color:rgba(0, 82, 217, 1);font-weight:600">工商信息</div>
                </template>
                <div class="flex marbot24" style="width:100%" v-if="addItem.customer_type == 1">
                    <div class="flex align_center" style="margin-right:36px;flex:1;">
                    <div class="font14 marbot4" style="width: 100px;">公司名称：</div>
                    <a-input v-model="addItem.company_data.companyName" placeholder="请输入公司名称" allow-clear  />
                    </div>
                    <div class="flex align_center" style="flex:1;margin-right:36px;" >
                    <div class="font14 marbot4" style="width: 100px;">公司类型：</div>
                    <a-input v-model="addItem.company_data.companyType" placeholder="请输入公司类型" allow-clear  />
                    </div>
                    <div class="flex align_center" style="flex:1;" >
                    <div class="font14 marbot4" style="width: 100px;">法定代表人：</div>
                    <a-input v-model="addItem.company_data.legalPerson" placeholder="请输入法定代表人" allow-clear  />
                    </div>
                </div>
                <div class="flex marbot24" style="width:100%" v-if="addItem.customer_type == 1">
                    <div class="flex align_center" style="margin-right:36px;flex:1;">
                    <div class="font14 marbot4" style="width: 100px;">法人类型：</div>
                    <a-input v-model="addItem.company_data.legalPersonType" placeholder="请输入法人类型" allow-clear  />
                    </div>
                    <div class="flex align_center" style="flex:1;margin-right:36px;" >
                    <div class="font14 marbot4" style="width: 100px;">电话号码：</div>
                    <a-input v-model="addItem.company_data.phoneNumber" placeholder="请输入电话号码" allow-clear  />
                    </div>
                    <div class="flex align_center" style="flex:1;" >
                    <div class="font14 marbot4" style="width: 100px;">电话备注：</div>
                    <a-input v-model="addItem.company_data.phoneNumber_note" placeholder="请输入电话备注" allow-clear  />
                    </div>
                </div>
                <div class="flex marbot24" style="width:100%" v-if="addItem.customer_type == 1">
                    <div class="flex align_center" style="margin-right:36px;flex:1;">
                    <div class="font14 marbot4" style="width: 100px;">注册资本：</div>
                    <a-input v-model="addItem.company_data.capital" placeholder="请输入注册资本" allow-clear  />
                    </div>
                    <div class="flex align_center" style="flex:1;margin-right:36px;" >
                    <div class="font14 marbot4" style="width: 100px;">实收注册资金：</div>
                    <a-input v-model="addItem.company_data.realCapital" placeholder="请输入实收注册资金" allow-clear  />
                    </div>
                    <div class="flex align_center" style="flex:1;" >
                    <div class="font14 marbot4" style="width: 100px;">注册码：</div>
                    <a-input v-model="addItem.company_data.companyCode" placeholder="请输入注册码" allow-clear  />
                    </div>
                </div>
                <div class="flex marbot24" style="width:100%" v-if="addItem.customer_type == 1">
                    <div class="flex align_center" style="margin-right:36px;flex:1;">
                    <div class="font14 marbot4" style="width: 100px;">企业信用代码：</div>
                    <a-input v-model="addItem.company_data.creditNo" placeholder="请输入企业信用代码" allow-clear  />
                    </div>
                    <div class="flex align_center" style="flex:1;margin-right:36px;" >
                    <div class="font14 marbot4" style="width: 100px;">组织机构代码：</div>
                    <a-input v-model="addItem.company_data.orgCode" placeholder="请输入组织机构代码" allow-clear  />
                    </div>
                    <div class="flex align_center" style="flex:1;" >
                    <div class="font14 marbot4" style="width: 100px;">经营范围：</div>
                    <a-input v-model="addItem.company_data.businessScope" placeholder="请输入经营范围" allow-clear  />
                    </div>
                </div>
                <div class="flex marbot24" style="width:100%" v-if="addItem.customer_type == 1">
                    <div class="flex align_center" style="margin-right:36px;flex:1;">
                    <div class="font14 marbot4" style="width: 100px;">登记机关：</div>
                    <a-input v-model="addItem.company_data.authority" placeholder="请输入登记机关" allow-clear  />
                    </div>
                    <div class="flex align_center" style="flex:1;margin-right:36px;" >
                    <div class="font14 marbot4" style="width: 100px;">经营状态：</div>
                    <a-input v-model="addItem.company_data.companyStatus" placeholder="请输入经营状态" allow-clear  />
                    </div>
                    <div class="flex align_center" style="flex:1;" >
                    <div class="font14 marbot4" style="width: 100px;">成立时间：</div>
                    <a-input v-model="addItem.company_data.establishDate" placeholder="请输入成立时间" allow-clear  />
                    </div>
                </div>
                <div class="flex marbot24" style="width:100%" v-if="addItem.customer_type == 1">
                    <div class="flex align_center" style="margin-right:36px;flex:1;">
                    <div class="font14 marbot4" style="width: 100px;">营业开始时间：</div>
                    <a-input v-model="addItem.company_data.operationStartdate" placeholder="请输入营业开始时间" allow-clear  />
                    </div>
                    <div class="flex align_center" style="flex:1;margin-right:36px;" >
                    <div class="font14 marbot4" style="width: 100px;">营业结束时间：</div>
                    <a-input v-model="addItem.company_data.operationEnddate" placeholder="请输入营业结束时间" allow-clear  />
                    </div>
                    <div class="flex align_center" style="flex:1;" >
                    <div class="font14 marbot4" style="width: 100px;">核准日期：</div>
                    <a-input v-model="addItem.company_data.issueDate" placeholder="请输入核准日期" allow-clear  />
                    </div>
                </div>
                <div class="flex marbot24" style="width:100%" v-if="addItem.customer_type == 1">
                    <div class="flex align_center" style="margin-right:36px;flex:1;">
                    <div class="font14 marbot4" style="width: 100px;">省份：</div>
                    <a-input v-model="addItem.company_data.province" placeholder="请输入省份" allow-clear  />
                    </div>
                    <div class="flex align_center" style="flex:1;margin-right:36px;" >
                    <div class="font14 marbot4" style="width: 100px;">省份行政区号：</div>
                    <a-input v-model="addItem.company_data.provinceCode" placeholder="请输入省份行政区号" allow-clear  />
                    </div>
                    <div class="flex align_center" style="flex:1;" >
                    <div class="font14 marbot4" style="width: 100px;">地市：</div>
                    <a-input v-model="addItem.company_data.city" placeholder="请输入地市" allow-clear  />
                    </div>
                </div>
                <div class="flex marbot24" style="width:100%" v-if="addItem.customer_type == 1">
                    <div class="flex align_center" style="margin-right:36px;flex:1;">
                    <div class="font14 marbot4" style="width: 100px;">地市行政区号：</div>
                    <a-input v-model="addItem.company_data.cityCode" placeholder="请输入地市行政区号" allow-clear  />
                    </div>
                    <div class="flex align_center" style="flex:1;margin-right:36px;" >
                    <div class="font14 marbot4" style="width: 100px;">地区：</div>
                    <a-input v-model="addItem.company_data.district" placeholder="请输入地区" allow-clear  />
                    </div>
                    <div class="flex align_center" style="flex:1;" >
                    <div class="font14 marbot4" style="width: 100px;">地区行政区号：</div>
                    <a-input v-model="addItem.company_data.districtCode" placeholder="请输入地区行政区号" allow-clear  />
                    </div>
                </div>
                <div class="flex marbot24" style="width:100%" v-if="addItem.customer_type == 1">
                    <div class="flex align_center" style="margin-right:36px;flex:1;">
                    <div class="font14 marbot4" style="width: 100px;">注册地址：</div>
                    <a-input v-model="addItem.company_data.companyAddress" placeholder="请输入注册地址" allow-clear  />
                    </div>
                    <div class="flex align_center" style="flex:1;margin-right:36px;" >
                    <div class="font14 marbot4" style="width: 100px;">行业：</div>
                    <a-input v-model="addItem.company_data.industry" placeholder="请输入行业" allow-clear  />
                    </div>
                    <div class="flex align_center" style="flex:1;" >
                    <div class="font14 marbot4" style="width: 100px;">曾用名：</div>
                    <a-input v-model="addItem.company_data.historyNames" placeholder="请输入曾用名" allow-clear  />
                    </div>
                </div>
                <div class="flex marbot24" style="width:100%" v-if="addItem.customer_type == 1">
                    <div class="flex align_center" style="margin-right:36px;flex:1;">
                    <div class="font14 marbot4" style="width: 100px;">更新时间：</div>
                    <a-input v-model="addItem.company_data.lastUpdatedTime" placeholder="请输入更新时间" allow-clear  />
                    </div>
                    <div class="flex align_center" style="flex:1;margin-right:36px;" >
                    <div class="font14 marbot4" style="width: 100px;">登记状态：</div>
                    <a-input v-model="addItem.company_data.companyStatus" placeholder="请输入登记状态" allow-clear  />
                    </div>
                    <div class="flex align_center" style="flex:1;" >
                    <div class="font14 marbot4" style="width: 100px;">邮箱：</div>
                    <a-input v-model="addItem.company_data.email" placeholder="请输入邮箱" allow-clear  />
                    </div>
                </div>
                <div class="flex marbot24" style="width:100%" v-if="addItem.customer_type == 1">
                    <div class="flex align_center" style="margin-right:36px;flex:1;">
                    <div class="font14 marbot4" style="width: 100px;">邮箱备注：</div>
                    <a-input v-model="addItem.company_data.email_note" placeholder="请输入邮箱备注" allow-clear  />
                    </div>
                    <div class="flex align_center" style="flex:1;margin-right:36px;" >
                    <div class="font14 marbot4" style="width: 100px;">地址：</div>
                    <a-input v-model="addItem.company_data.address" placeholder="请输入地址" allow-clear  />
                    </div>
                    <div class="flex align_center" style="flex:1;" >
                    <div class="font14 marbot4" style="width: 100px;">地址备注：</div>
                    <a-input v-model="addItem.company_data.address_note" placeholder="请输入地址备注" allow-clear  />
                    </div>
                </div>
                <div class="flex marbot24" style="width:100%" v-if="addItem.customer_type == 1">
                    <div class="flex align_center" style="margin-right:36px;flex:1;">
                    <div class="font14 marbot4" style="width: 100px;">网址：</div>
                    <a-input v-model="addItem.company_data.website" placeholder="请输入网址" allow-clear  />
                    </div>
                    <div class="flex align_center" style="flex:1;margin-right:36px;" >
                    <div class="font14 marbot4" style="width: 100px;">网址备注：</div>
                    <a-input v-model="addItem.company_data.website_note" placeholder="请输入网址备注" allow-clear  />
                    </div>
                    <div class="flex align_center" style="flex:1;" >
                    
                    </div>
                </div>
                <div class="flex marbot24" style="width:100%" v-if="addItem.customer_type == 2">
                    <div class="flex align_center" style="flex:1;">
                    <div class="font14 marbot4" style="width: 100px;">抬头名称：</div>
                    <a-input v-model="addItem.companyName" placeholder="请输入抬头名称" allow-clear  />
                    </div>
                </div>
                </a-card>
            </div>
            <div >
                <a-card  :header-style="{background:'#f5f5f5',color:'rgba(0, 82, 217, 1)',fontWeight:'600'}">
                <template #title>
                    <div style="color:rgba(0, 82, 217, 1);font-weight:600">银行账户信息</div>
                </template>
                <div class="flex marbot24" style="width:100%">
                    <div class="flex align_center" style="margin-right:36px;flex:1;">
                    <div class="font14 marbot4" style="width: 100px;">开户银行：</div>
                    <a-input v-model="addItem.opening_bank" placeholder="请输入开户银行" allow-clear  />
                    </div>
                    <div class="flex align_center" style="flex:1;">
                    <div class="font14 marbot4" style="width: 100px;">银行账号：</div>
                    <a-input v-model="addItem.account" placeholder="请输入银行账号" allow-clear  />
                    </div>
                </div>
                <div class="flex marbot24" style="width:100%">
                    <div class="flex align_center" style="margin-right:36px;flex:1;">
                    <div class="font14 marbot4" style="width: 100px;">账户名称：</div>
                    <a-input v-model="addItem.account_name" placeholder="请输入账户名称" allow-clear  />
                    </div>
                    <div style="flex:1;">
                    
                    </div>
                </div>
                </a-card>
            </div>
            </div>
        </a-modal>

        <!-- 新增合同 -->
        <a-modal :mask-closable="false"  v-model:visible="showSaveHt" title="新增合同" @cancel="showSaveHt = false" :width="800" :footer="false">
            <div class="contenBox" style="overflow: auto;" >
                <ma-form v-model="saveHtform" :columns="saveHtColumns" ref="saveHtFormRef" @submit="saveHtSub" v-if="showSaveHt" />
            </div>
        </a-modal>
    </div>
    
</template>




<script setup>
    import { ref, reactive, onMounted, onActivated, defineProps, nextTick, shallowRef } from "vue";
    import predictionManage from "@/api/prediction/predictionManage";
    import commonApi from "@/api/common";
    import { pinyin } from "pinyin-pro"
    import bill from "@/components/bill/index.vue"
    import { request } from "@/utils/request.js";
    import tool from '@/utils/tool'
	import htgsComponent from "./htgsComponent.vue";
	import systemUserContract from "@/api/system/systemUserContract";
    import dept from "@/api/system/dept";
    import { Message,Modal } from '@arco-design/web-vue'
    const emits = defineEmits(['succ'])
    const env = ref(import.meta.env);
    // 新增合同
    const showSaveHt = ref(false)
    const saveHtFormRef = ref(false)
    const loading = ref(false)
    const deptSearchList = ref([])
    const saveHtform = ref({})
    const carTypeData = ref([])
    const handleCarTypeSearch = (value)=>{
        // carTypeData.value = carTypeData.value.filter(item => item.includes(value));
        // console.log("handleCarTypeSearch:",carTypeData.value)
    }
    const carTypeSaveHistory = ()=>{
        const value = itemData.value.car_type.trim();
        if (value && !carTypeData.value.includes(value)) {
            carTypeData.value = [value, ...carTypeData.value].slice(0, 10); // 最多保留10条
            localStorage.setItem('car_type', JSON.stringify(carTypeData.value));
        }

    }
    const tuoyunData = ref([])
    const handleTuoyunSearch = (value)=>{
        // tuoyunData.value = tuoyunData.value.filter(item => item.includes(value));
    }
    const tuoyunSaveHistory = ()=>{
        const value = itemData.value.shipper.trim();
        if (value && !tuoyunData.value.includes(value)) {
            tuoyunData.value = [value, ...tuoyunData.value].slice(0, 10); // 最多保留10条
            localStorage.setItem('tuoyun', JSON.stringify(tuoyunData.value));
        }
    }
    const tuoyunUserData = ref([])
    const handleTuoyunUserSearch = (value)=>{
        // tuoyunUserData.value = tuoyunUserData.value.filter(item => item.includes(value));
    }
    const tuoyunUserSaveHistory = ()=>{
        const value = itemData.value.shipper_agent.trim();
        if (value && !tuoyunUserData.value.includes(value)) {
            tuoyunUserData.value = [value, ...tuoyunUserData.value].slice(0, 10); // 最多保留10条
            localStorage.setItem('tuoyunUser', JSON.stringify(tuoyunUserData.value));
        }
    }
    const tuoyunPhoneData = ref([])
    const handleTuoyunPhoneSearch = (value)=>{
        // tuoyunPhoneData.value = tuoyunPhoneData.value.filter(item => item.includes(value));
    }
    const tuoyunPhoneSaveHistory = ()=>{
        const value = itemData.value.shipper_phone.trim();
        if (value && !tuoyunPhoneData.value.includes(value)) {
            tuoyunPhoneData.value = [value, ...tuoyunPhoneData.value].slice(0, 10); // 最多保留10条
            localStorage.setItem('tuoyunPhone', JSON.stringify(tuoyunPhoneData.value));
        }
    }
    const kehuUserData = ref([])
    const handleKehuUserSearch = (value)=>{
        // kehuUserData.value = kehuUserData.value.filter(item => item.includes(value));
    }
    const kehuUserSaveHistory = ()=>{
        const value = itemData.value.customer_handler.trim();
        if (value && !kehuUserData.value.includes(value)) {
            kehuUserData.value = [value, ...kehuUserData.value].slice(0, 10); // 最多保留10条
            localStorage.setItem('kehuUser', JSON.stringify(kehuUserData.value));
        }
    }
    const baozhuangData = ref([])
    const handleBaozhuangSearch = (value)=>{
        // baozhuangData.value = baozhuangData.value.filter(item => item.includes(value));
    }
    const baozhuangSaveHistory = (index)=>{
        const value = itemData.value.goods_data[index].baozhuang.trim();
        if (value && !baozhuangData.value.includes(value)) {
            baozhuangData.value = [value, ...baozhuangData.value].slice(0, 10); // 最多保留10条
            localStorage.setItem('baozhuang', JSON.stringify(baozhuangData.value));
        }
    }
    const saveHtColumns = reactive([
		{
			title: "合同名称",
			dataIndex: "name",
			formType: "input",
			width:180,
			align: "center",
			search: true,
			commonRules: {
				required: true,
				message: "请输入合同名称",
			},
		},
		{
			title: "合同号",
			dataIndex: "contract_no",
			formType: "input",
			align: "center",
			width:180,
			search: true,
			commonRules: {
				required: true,
				message: "请输入合同号",
			},
		},
		{
			title: "合同公司",
			dataIndex: "dept_id",
			align: "center",
			formType: "component",
			component: shallowRef(htgsComponent),
			// width:180,
			search: true,
			// dict: {
			// 	// 远程通用接口请求，新版代码生成都有一个 remote 接口
			// 	remote: "system/dept/remote",
			// 	// 指定组件接收的props
			// 	props: { label: "name", value: "id" },
			// 	// 开启分页
			// 	openPage: false,
			// 	// 远程请求配置项
			// 	remoteOption: {
			// 		// 按用户名排序
			// 		sort: { id: "desc" }, // 如果不指定排序方式，默认为正序排序
			// 		// 设置查询的字段
			// 		select: ["id", "name"],
			// 		// 设置数据过滤
			// 		filter: {
			// 			type: ["=", 2],
			// 		},
			// 		// 关联模型
			// 		relations: [],
			// 	},
			// },
			commonRules: {
				required: true,
				message: "请选择合同公司",
			},
		},
		{ title: '免费堆放天数', dataIndex: 'zc_day',  align:'center',width: 120,formType:'input' },
		{
			
			dataIndex: "charge_type",
			formType: "radio",
			title: "计费政策",
			align: "center",
			hide:true,
			control: (val) => {
				if (val == 1) {
					return {
						template_id: { display: true },
					}
				}
				if (val == 2) {
					return {
						template_id: { display: false },
					}
				}
			},
			dict: {
				data()
				{
				return [
					{label: "公示价格", value: 1},
					{label: "一企一策", value: 2},
				]
				},
				translation: true
			},
			commonRules: {
				required: true,
				message: "请选择计费政策"
			},
			
		},
		{
			title: "计费模版",
			dataIndex: "template_id",
			align: "center",
			formType: "select",
			width:180,
			display:false,
			editDisplay:false,
			hide:true,
			dict: {
				// 远程通用接口请求，新版代码生成都有一个 remote 接口
				url: "system/template/index",
				method:'GET',
				// 指定组件接收的props
				props: { label: "name", value: "id" },
				// 开启分页
				openPage: false,
				// 远程请求配置项
				remoteOption: {
					// 设置查询的字段
					select: ["id", "name"],
					// 关联模型
					relations: [],
				},
			},
			commonRules: {
				required: true,
				message: "请选择计费模版",
			},
		},
		{
			title: "合同附件",
			dataIndex: "annex",
			align: "center",
			formType: "upload",
			type: "file",
			multiple: true,
			returnType: "url",
		},
		{
			title: "开始时间",
			dataIndex: "start_time",
			align: "center",
			formType: "date",
			search: false,
			addDisabled:false,
			editDisabled:true,
			showTime: true,
			commonRules: {
				required: true,
				message: "请选择开始时间"
			},
		},
		{
			title: "结束时间",
			dataIndex: "end_time",
			align: "center",
			formType: "date",
			addDisabled:false,
			editDisabled:true,
			search: false,
			showTime: true,
			disabledDate:(current) => {
				// return true

				let newData = new Date(current).getTime()    //  每一天的时间戳
				let newDatas = new Date(saveHtFormRef.value.getFormData().start_time).getTime()    //  开始时间戳
				if(newData < newDatas){
					return true
				}else{
					return false
				}
				
				
			},
			commonRules: {
				required: true,
				message: "请选择结束时间"
			}
		},
    {
      title: "结算方式",
      dataIndex: "pay_method",
      align: "center",
      formType: "checkbox",
	  width:180,
      addDefaultValue: 1,
    //   search: true,
      commonRules: {
        required: true,
        message: "请选择支付方式",
      },
      dict: {
        data: [
          {label: '预付', value: '1'},
          {label: '周期结算', value: '2'},
          {label: '现结', value: '3'},
        ],
        translation: true,
      },
    }
	]);
    const saveHt = () => {
        showSaveHt.value = true
    }
    const saveHtSub = (data,done) => {
        let subData = saveHtform.value
        subData.pay_method = subData.pay_method.join(",")
        if (data) {
            systemUserContract.save(subData).then( res => {
                if (res.code == 200 && res.success) {
                    Message.success('提交成功')
                    showSaveHt.value = false
                    saveHtFormRef.value.resetForm()
                    if(!itemData.value.dept_id){
                        return
                    }
                    request({
                        url: 'system/userContract/remote_prediction?dept_id=' + itemData.value.dept_id,
                        method: 'get',
                        params: {
                            pageSize: 1000,
                        }
                    }).then(res => {
                        contractList.value = res.data
                        if(res.data.length == 1){
                            itemData.value.contract_id = res.data[0].id
                            handlechangeadderr(res.data[0].id)
                        }
                    })
                    dept_list.value.map((v,i)=>{
                        if(v.id == itemData.value.dept_id){
                            itemData.value.customer_handler = v.leader
                            itemData.value.customer_tel = v.phone
                        }
                    })



                }
            }).catch( e => {
                console.error(e)
                Message.error('提交失败')
            })
        }
    }

    const showSpin = ref(true)

    const showBill = ref(false)
    const billData = ref({})
    const props = defineProps({
        // dept_list:{
        //     default:[]
        // },
        yunshuList:{
            default:[]
        },
        goods_list:{
            default:[]
        },
        fuwuList:{
            default:[]
        }
    })
    const serviceList = ref([
        {
            title:'站到站',
            key:'1'
        },
        {
            title:'站到门',
            key:'2'
        },
        {
            title:'门到站',
            key:'3'
        },
        {
            title:'门到门',
            key:'4'
        },
        
    ])
    const is_emptyList = ref([
        {
            title:'空箱',
            key:'1'
        },
        {
            title:'重箱',
            key:'2'
        },
    ])
    const box_belongList = ref([
        { key: '铁路箱', title: "铁路箱" },
        { key: '自备箱', title: "自备箱" },
    ])
    const filterOption = (v,option)=>{
    return option.keywords.some(keywords=>keywords.includes(v))
    }
    const sendList = ref([])   // 站列表
    const sendJuList = ref([])   // 发站局列表
    const arriveJuList = ref([])   // 到站局列表
    const contractList = ref([])   // 合同列表
    const peisongaddrrList = ref([])   // 配送地址
    const boxTypeList = ref([])

    const list = ref([])
    const goodList = ref([{}])
    const center = ref(0)
    const itemDatas = ref({})
    const is_nobody = ref(false)
    const itemData = ref({
        car_type:'',  // 车种
        car_no:'',  // 车号
        notice_time:'',  // 通知时间
        transport_type:'1',  // 运输方式
        service_type:'',  //  服务方式
        shipper:'',   // 托运人
        shipper_agent:'',   // 托运经办人
        shipper_phone:'',   // 托运人电话
        sending_station:'',   // 发站
        sending_tlj:'',   // 发 铁路局
        sending_station_special:'',  // 发站专用线
        come_address:'',   // 到站
        come_tlj:'',   // 到 铁路局
        arrive_station_special:'',  // 到站专用线
        dept_id:'',   // 客户
        customer_handler:'',   // 客户经办人
        customer_tel:'',    // 客户电话
        contract_id:'',   // 合同
        serve_type:'3',   // 是否仓储
        shipping_tel:'',   // 配送电话
        shipping_address:'',   // 配送地址
        goods_data:[],
        is_nobody:0,
        pdf_url:""
    })
    const isNobodyChange = (e) => {
        itemData.value.is_nobody = e?1:0
    }

    const goods_data = ref([
        {
            ticket_number:'',  
            goods_id:'',  
            baozhuang:'',  
            box:'',  
            is_empty:'2',  
            box_type:'',  
            box_type_id:'',  
            box_belong:'',
            number_yu:'',  
            hz_weight:'',  
            bz_weight:'',  
            jf_weight:'',  
            cyr_weight:'', 
        }
    ])
    const chongGouList = ref([])
    const objectData = ref({
        page:1,
        pageSize:1000,
        ticket_number:'',
        car_no:'',
        box:'',
        // is_hebing:2,
        // is_compled:0
        match_customer:1
    })
    const boxData = ref([
        {
            ticket_number:'',  
            goods_id:'',  
            baozhuang:'',  
            box:'',  
            is_empty:'2',  
            box_type:'',  
            box_type_id:'',  
            box_belong:'',
            number_yu:'',  
            hz_weight:'',  
            bz_weight:'',  
            jf_weight:'',  
            cyr_weight:'', 
            size:'',
            caozuo:'',
            type:1
        },
        {
            ticket_number:'',  
            goods_id:'',  
            baozhuang:'',  
            box:'',  
            is_empty:'2',  
            box_type:'',  
            box_type_id:'',  
            box_belong:'',
            number_yu:'',  
            hz_weight:'',  
            bz_weight:'',  
            jf_weight:'',  
            cyr_weight:'',  
            size:'',
            caozuo:'',
            type:2
        }
    ])
    
    const zhengcheData = ref([
        {
            ticket_number:'',  
            goods_id:'',  
            baozhuang:'',  
            number_yu:'',  
            hz_weight:'',  
            bz_weight:'',  
            jf_weight:'',  
            cyr_weight:'', 
            caozuo:'',
            type:1
        },
    ])
    const plkyData = ref([
        {
            ticket_number:'',  
            goods_id:'',  
            baozhuang:'',  
            number_yu:'',  
            hz_weight:'',  
            bz_weight:'',  
            jf_weight:'',  
            cyr_weight:'', 
            size:'',
            caozuo:'',
            type:1
        },
    ])
    const handleYinhanInfo = (e)=>{
        console.log(e)
        deptSearchList.value.map((v,i)=>{
        if(v.creditNo == e){
            addItem.value.name = v.companyName
        }
        })
        request({
        url:'system/dept/getCompanyDetail',
        method: 'get',
        params:{
            keyword:e,
            
        },
        }).then(res=>{
        console.log('银行信息：',res)
        let _data = res.data
        addItem.value.company_data.companyType = _data.companyType
        addItem.value.company_data.legalPersonType = _data.legalPersonType
        addItem.value.company_data.phoneNumber = _data.contacts.phoneNumber[0].value || ''
        addItem.value.company_data.phoneNumber_note = _data.contacts.phoneNumber[0].note  || ''
        addItem.value.company_data.capital = _data.capital
        addItem.value.company_data.realCapital = _data.realCapital
        addItem.value.company_data.orgCode = _data.orgCode
        addItem.value.company_data.businessScope = _data.businessScope
        addItem.value.company_data.authority = _data.authority
        addItem.value.company_data.operationStartdate = _data.operationStartdate
        addItem.value.company_data.operationEnddate = _data.operationEnddate
        addItem.value.company_data.issueDate = _data.issueDate
        addItem.value.company_data.province = _data.province
        addItem.value.company_data.provinceCode = _data.provinceCode
        addItem.value.company_data.city = _data.city
        addItem.value.company_data.cityCode = _data.cityCode
        addItem.value.company_data.district = _data.district
        addItem.value.company_data.districtCode = _data.districtCode
        addItem.value.company_data.industry = _data.industry
        addItem.value.company_data.historyNames = _data.historyNames
        addItem.value.company_data.lastUpdatedTime = _data.lastUpdatedTime
        addItem.value.company_data.email = _data.contacts.email[0].value || ''
        addItem.value.company_data.email_note = _data.contacts.email[0].note  || ''
        addItem.value.company_data.address = _data.contacts.address[0].value  || ''
        addItem.value.company_data.address_note = _data.contacts.address[0].note || ''
        addItem.value.company_data.website = _data.contacts.website[0].value || ''
        addItem.value.company_data.website_note = _data.contacts.website[0].note || ''
        console.log(addItem.value)
        })
    }
    const handleDaofazhangData = ()=>{
        request({
            url: 'prediction/dfz/index',
            method: 'get',
            params: {
                pageSize: 5000,
            }
        }).then(res => {
            res.data.items.map((v,i)=>{
                    v.keywords = [
                    v.name,
                    pinyin(v.name,{toneType:'none',pattern:'first'}).split(' ').join(''),
                    pinyin(v.name,{toneType:'none',pattern:'first'}).split(' ').join('').toUpperCase()
                    ]
                    if(itemDatas.value){
                        if(v.id == itemDatas.value.fzs.id){
                            sendJuList.value = [v.tlj]
                        }
                        if(v.id == itemDatas.value.dzs.id){
                            arriveJuList.value = [v.tlj]
                        }
                    }
                    
            })
            sendList.value = res.data.items
        })
    }
    onMounted(()=>{
        request({
            url: "prediction/boxManage/index",
            method: "get",
            params: {
            openPage: false,
            },
        }).then((res) => {
            boxTypeList.value = res.data.items;

        });
        handleDaofazhangData()
        handleChongGouList()
        handleDeptList()
        getTagList()
        const tuoyunHistory = localStorage.getItem('tuoyun');
        tuoyunData.value = tuoyunHistory ? JSON.parse(tuoyunHistory) : [];
        const savedHistory = localStorage.getItem('tuoyunUser');
        tuoyunUserData.value = savedHistory ? JSON.parse(savedHistory) : [];
        const phoneHistory = localStorage.getItem('tuoyunPhone');
        tuoyunPhoneData.value = phoneHistory ? JSON.parse(phoneHistory) : [];
        const kehuUserHistory = localStorage.getItem('kehuUser');
        kehuUserData.value = kehuUserHistory ? JSON.parse(kehuUserHistory) : [];
        const baozhuangHistory = localStorage.getItem('baozhuang');
        baozhuangData.value = baozhuangHistory ? JSON.parse(baozhuangHistory) : [];
        const carTypeHistory = localStorage.getItem('car_type');
        carTypeData.value = carTypeHistory ? JSON.parse(carTypeHistory) : [];
    })
    const dept_list = ref([])
    const handleDeptList = () => {   //  获取公司列表
        request({
            url: 'system/dept/index',
            method: 'get',
            data: {
            openPage: false,
            remoteOption: {
                filter: {
                type: ['=', 2],
                status: ["=",1]
                },
                select: ["id", "name"],
                sort: { id: "desc" }
            }
            }
        }).then(res => {
            let arr = []
            res.data.map((v,i)=>{
                v.keywords = [
                v.name,
                pinyin(v.name,{toneType:'none',pattern:'first'}).split(' ').join(''),
                pinyin(v.name,{toneType:'none',pattern:'first'}).split(' ').join('').toUpperCase()
                ]
                if(v.status == 1){
                arr.push(v)
                }
            })
            dept_list.value = arr
        })
    }


    const handlePre = ()=>{
        if(center.value > 0){
            center.value--
            itemDatas.value = chongGouList.value[center.value]
            chulishuju()
        }else{
            Message.error('没有上一条数据了')
        }
    }
    const handleNext = ()=>{
        if(center.value < chongGouList.value.length){
            center.value++
            itemDatas.value = chongGouList.value[center.value]
            chulishuju()
        }else{
            Message.error('没有新数据了')
        }
    }
    const handleAdd = ()=>{
        let goods_id = itemData.value.goods_data[itemData.value.goods_data.length -1].goods_id
        itemData.value.goods_data.push({
            ticket_number:'',  
            goods_id:goods_id,  
            baozhuang:'',  
            box:'',  
            is_empty:'2',  
            box_type:'',  
            box_type_id:'',  
            box_belong:'',
            number_yu:'',  
            hz_weight:'',  
            bz_weight:'',  
            jf_weight:'',  
            cyr_weight:'', 
        })
    }
    const handleDel = (index) =>{
        itemData.value.goods_data.splice(index,1) 
    }
    const handleChangeGood = (e)=>{
        itemData.value.goods_data.map((v,i)=>{
            v.goods_id = e
        })
    }
    const handleChangeBoxBelong = (e)=>{
        itemData.value.goods_data.map((v,i)=>{
            if(!v.box_belong){
                v.box_belong = e
            }
        })
    }
    const handleSearch = (value) => {
        if (value) {
        loading.value = true;
        request({
            url:'system/dept/info',
            method: 'get',
            params:{
            keyword:value,
            pageNo:1,
            pageSize:1000,
            },
        }).then(res=>{
            console.log('公司信息：',res)
            deptSearchList.value = res.data.items
            loading.value = false;
        })
        } else {
        deptSearchList.value = []
        }
    };
    const handleChangeDept = (e) =>{
        request({
            url: 'system/userContract/remote_prediction?dept_id=' + e,
            method: 'get',
            params: {
                pageSize: 1000,
            }
        }).then(res => {
            contractList.value = res.data
            if(res.data.length == 1){
                itemData.value.contract_id = res.data[0].id
                handlechangeadderr(res.data[0].id)
            }
        })
        dept_list.value.map((v,i)=>{
            if(v.id == e){
                itemData.value.customer_handler = v.customer_type == 1?v.leader:v.name
                itemData.value.customer_tel = v.phone
            }
        })
    }
    const handleSendChange = (e,type)=>{
        console.log('888888888888888888888888888888888')
        if(type == 1){
            sendList.value.map((v,i)=>{
                if(v.id == e){
                    sendJuList.value = [v.tlj]
                    itemData.value.sending_tlj = v.tlj.id
                }
            })
        }else{
            sendList.value.map((v,i)=>{
                if(v.id == e){
                    arriveJuList.value = [v.tlj]
                    itemData.value.come_tlj = v.tlj.id
                }
            })
        }
        
    }
    const handleSouSuo = (item) =>{   //搜索
        objectData.value.page = 1
        console.log("点击收缩")
        handleChongGouList()
    }
    const handleChongZhi = (item) =>{   //搜索
        objectData.value.page = 1
        objectData.value.ticket_number = ''
        objectData.value.car_no = ''
        objectData.value.box = ''
        center.value = 0
        handleChongGouList()
    }
    const daShpwloading = ref(true)
    const handlePdf = (id)=>{
        daShpwloading.value = true
        console.log('id:',itemData.value)
        const queryString = new URLSearchParams({ticket_numbers:itemData.value.ticket_number}).toString();
        fetch(`https://pdf.chuangxing.ren/api/index/get_pdf_url?${queryString}`,{
        headers:{
            'Content-Type': 'application/json',
        }
        })
        .then(response => response.json())
        .then(data => {
            if(data.code == 1){
                itemData.value.pdf_url = data.data
                daShpwloading.value = true
                setTimeout(() => {
                    daShpwloading.value = false
                },1000)
            }else{
                Message.error(data.msg)
            }
            
        })
        .catch(error => console.error('Error:', error));
    }
    const initloading = ref(false)
    const handleChongGouList = async () => {
        initloading.value = true
        let list = []
        await request({
            url: 'goods/manage/index',
            method: 'get',
            params:{
                pageSize:100,
            }
        }).then(res => {
            let _data = res.data.items
            // 
            _data.map((v,i)=>{
                v.goods_id = v.id
                // v.name =  v.type.name + '-' +  v.name
            })
            list = _data
            initloading.value = false
        }).catch(e => {
            console.error(e)
            initloading.value = false
        })
        initloading.value = true
        predictionManage.getList(objectData.value).then(  res => {
            
            initloading.value = false
            if (res.code == 200) {
                let _data = res.data.items
                let newArr = []
                let zuiArr = []
                _data.map((v, i) => {
                    if (v.load_detail == null) {   // 未生成装卸任务
                        v.load = 3
                    } else if (v.load_detail.detail_load_status == 0) { // 已生成装卸任务
                        v.load = 2
                    } else if (v.load_detail.detail_load_status == 1) { // 已生成装卸任务
                        v.load = 1
                    }
                    v.weight = (v.weight - 0).toFixed(3);
                    v.weight_yu = (v.weight_yu - 0).toFixed(3);
                    v.yb_weight = (v.yb_weight - 0).toFixed(3);
                    v.goods_ids = v.goods_id
                    v.transport_type = v.transport_type + ''
                    v.serve_type = v.serve_type + ''
                    v.dept_id = v.dept_id == 0? '' : v.dept_id
                    v.goods_id = v.goods_id == 0? '' : v.goods_id
                    v.contract_id = v.contract_id == 0? '' : v.contract_id
                    v.goods_list = list 
                    if(v.goods_data != null){
                        if (typeof v.goods_data === 'object' && Array.isArray(v.goods_data)) {
                            v.goods_data = v.goods_data
                        } else if (typeof v.goods_data === 'object' && !Array.isArray(v.goods_data)) {
                            v.goods_data = [v.goods_data];
                        }
                        v.goods_data.map((vv,ii)=>{
                            if(vv.is_empty){
                                
                                vv.is_empty = vv.is_empty + ''
                            }
                            if(vv.goods_id == 0){
                                vv.goods_id = ''
                            }
                        })
                    }
                    if(!newArr.includes(v.yundanhao)){
                        newArr.push(v.yundanhao) 
                    }
                });
                newArr.map((v,i)=>{
                    _data.map((vv,ii)=>{
                        if(v == vv.yundanhao){
                            zuiArr[i] = vv
                        }
                    })
                })
                let colnArr = JSON.parse(JSON.stringify(zuiArr))
                colnArr.map((v,i)=>{
                    v.ids = []
                    v.goods_data = []
                })
                colnArr.map((v,i)=>{
                    v.ticket_numbers = []
                    _data.map((vv,ii)=>{
                        if(v.yundanhao == vv.yundanhao){
                            if(vv.goods_data != null){
                            	if (typeof vv.goods_data === 'object' && Array.isArray(vv.goods_data) && vv.goods_data.length == 1) {
                                    v.goods_data.push(vv.goods_data[0])
                                }else if (typeof vv.goods_data === 'object' && Array.isArray(vv.goods_data) && vv.goods_data.length == 2) {
                                    v.goods_data = vv.goods_data
                                } else if (typeof vv.goods_data === 'object' &&!Array.isArray(vv.goods_data)) {
                                    v.goods_data.push(vv.goods_data)
                                }
                            }
                            v.ids.push(vv.id)
                            v.ticket_numbers.push(vv.ticket_number)
                        }
                    })
                    v.ticket_numbers = removeDuplicates(v.ticket_numbers).join(',')
                })
                
                console.log('colnArr:',colnArr)

                chongGouList.value = colnArr

                itemDatas.value = colnArr[0]
                
                chulishuju()
                
            }
        }).catch(e => {
            console.error(e)
            initloading.value = false

        })
    }
    // 数组字符串去重
    const removeDuplicates = (arr)=>{
        return arr.filter((item, index) => arr.indexOf(item) === index);
    }
    const chulishuju = () =>{
        
        console.log('itemDatas:',itemDatas.value)
        if(itemDatas.value){
            itemData.value.car_type = itemDatas.value.car_type
            itemData.value.car_no = itemDatas.value.car_no
            itemData.value.ticket_number = itemDatas.value?.ticket_numbers
            itemData.value.transport_type = itemDatas.value.transport_type
            itemData.value.service_type = itemDatas.value.service_type == null?'': itemDatas.value.service_type + ''
            itemData.value.shipper_agent = itemDatas.value.shipper_agent
            itemData.value.shipper = itemDatas.value.shipper
            itemData.value.shipper_phone = itemDatas.value.shipper_phone
            itemData.value.sending_station_special = itemDatas.value.sending_station_special
            itemData.value.customer_handler = itemDatas.value.customer_handler
            itemData.value.customer_tel = itemDatas.value.customer_tel
            itemData.value.customer_tel = itemDatas.value.customer_tel
            itemData.value.arrive_station_special = itemDatas.value.arrive_station_special
            itemData.value.shipping_tel = itemDatas.value.shipping_tel
            itemData.value.serve_type = itemDatas.value.serve_type + ''
            itemData.value.id = itemDatas.value.id
            itemData.value.ids = itemDatas.value.ids
            itemData.value.dept_id = itemDatas.value.dept_id
            itemData.value.come_address = itemDatas.value.come_address
            itemData.value.come_tlj = itemDatas.value.dzs.tlj_id
            itemData.value.sending_tlj = itemDatas.value.fzs.tlj_id
            itemData.value.come_address = itemDatas.value.come_address
            itemData.value.sending_station = itemDatas.value.sending_station == 0?'':itemDatas.value.sending_station - 0
            itemData.value.goods_data = itemDatas.value.goods_data
            itemData.value.is_nobody = itemDatas.value.is_nobody ? itemDatas.value.is_nobody - 0 : 0
            is_nobody.value = itemDatas.value.is_nobody == 1? true : false
            itemData.value.notice_time = itemDatas.value.notice_time || tool.dateFormat(
                Math.round(new Date().getTime() / 1000).toString(),
                "yyyy-MM-dd hh:mm:ss"
            )
            sendList.value = [JSON.parse(JSON.stringify(itemDatas.value.dzs)),JSON.parse(JSON.stringify(itemDatas.value.fzs))]
            // handleSendChange(itemDatas.value.come_address - 0,2)
            // handleSendChange(itemDatas.value.sending_station - 0,1)
            handleChangeDept(itemDatas.value.dept_id)
            handlePdf()
            showSpin.value = false
        }else{
            itemData.value = {
                car_type:'',  // 车种
                car_no:'',  // 车号
                notice_time:'',  // 通知时间
                transport_type:'1',  // 运输方式
                service_type:'',  //  服务方式
                shipper:'',   // 托运人
                shipper_agent:'',   // 托运经办人
                shipper_phone:'',   // 托运人电话
                sending_station:'',   // 发站
                sending_tlj:'',   // 发 铁路局
                sending_station_special:'',  // 发站专用线
                come_address:'',   // 到站
                come_tlj:'',   // 到 铁路局
                arrive_station_special:'',  // 到站专用线
                dept_id:'',   // 客户
                customer_handler:'',   // 客户经办人
                customer_tel:'',    // 客户电话
                contract_id:'',   // 合同
                serve_type:'3',   // 是否仓储
                shipping_tel:'',   // 配送电话
                shipping_address:'',   // 配送地址
                goods_data:[
                    {
                        ticket_number:'',  
                        goods_id:"",  
                        baozhuang:'',  
                        box:'',  
                        is_empty:'2',  
                        box_type:'',  
                        box_type_id:'',  
                        box_belong:'',
                        number_yu:'',  
                        hz_weight:'',  
                        bz_weight:'',  
                        jf_weight:'',  
                        cyr_weight:'', 
                    }
                ],
                is_nobody:0,
                pdf_url:"" 
            }
            showSpin.value = false
        }
        
    }
    const handlechangeadderr = (e) =>{   // 获取合同配送地址
        request({
            url: '/system/userContractAddress/index?contract_id=' + e,
            method: 'get',
        }).then(res=>{
            if(res.data.items.length != 0){
                itemData.value.shipping_address = res.data.items[0].id
                itemData.value.shipping_tel = res.data.items[0].mobile
            }
           
            peisongaddrrList.value = res.data.items
        })
    }
    const handleChangeBoxType = (e,index)=>{
        boxTypeList.value.map((v,i)=>{
            if(v.id == e){
                itemData.value[index].goods_data.box_type = v.name
            }
        })
    }
    const handleBaoCun = (tab)=>{
        if(!areValuesNotEmpty(itemData.value)){
            return Message.error('请添加数据，数据不能为空')
        }
        let requestData = JSON.parse(JSON.stringify(itemData.value))
        let jsonData = []
        requestData.goods_data.map((v,i)=>{
            jsonData.push(v)
        })

        let number_yu = 0
        let hz_weight = 0
        let jf_weight = 0
        let bz_weight = 0
        let cyr_weight = 0
        console.log(jsonData)
        if(!areAllValuesDefined(jsonData)){
            return Message.error('请添加数据，表格中数据不能为空')
        }
        let ticket_numberArr = []
        jsonData.map((v,i)=>{
            number_yu += (v.number_yu - 0)
            hz_weight += (v.hz_weight - 0)
            jf_weight += (v.jf_weight - 0)
            bz_weight += (v.bz_weight - 0)
            cyr_weight += (v.cyr_weight - 0)
            ticket_numberArr.push(v.ticket_number)
        })
        requestData.ticket_number = ticket_numberArr.join(',')
        requestData.number_yu = number_yu
        requestData.hz_weight = hz_weight
        requestData.jf_weight = jf_weight
        requestData.bz_weight = bz_weight
        requestData.cyr_weight = cyr_weight
        requestData.goods_id = jsonData[0].goods_id
        requestData.goods_data = jsonData
        requestData.type = 1
        console.log('传输的数据：',requestData)
        predictionManage.save(requestData).then(res=>{
            if(res.code == 200){
                Message.success('匹配成功！')
                if(tab == 1){
                    // emits('succ')
                    handleNext()
                }else{
                    billData.value.ids = res.data.id.join(',')
                    billData.value.dept_id = itemData.value.dept_id
                    billData.value.transport_type = itemData.value.transport_type
                    console.log('billData:',billData.value)
                    showBill.value = true
                    handleNext()
                }
            }
        })
    }
    const zhangdanshuaxin = ()=>{
        showBill.value = false
        // handleNext()
    }

    // 判断对象里面的值不能为空
    const areValuesNotEmpty = (obj)=>{
        for (const key in obj) {
            if(key == 'transport_type'){
                if(obj[key] == 2){
                    if(!obj['car_type']){
                        return false
                    }
                }
            }
            if(is_nobody.value){
                if (obj.hasOwnProperty(key) && !obj[key] 
                        && key != 'transport_type' 
                        && key != 'car_no' 
                        && key != 'shipper_agent' 
                        && key != 'shipper_phone' 
                        && key != 'dept_id' 
                        && key != 'service_type' 
                        && key != 'contract_id' 
                        && key != 'customer_handler' 
                        && key != 'customer_tel' 
                        && key != 'notice_time' 
                        && key != 'shipping_address' 
                        && key != 'shipping_tel' 
                        && key != 'car_type' 
                        && key != 'is_nobody'
                        && key != 'pdf_url') {
                    return false;
                }
            }else{
                if (obj.hasOwnProperty(key) && !obj[key] 
                        && key != 'transport_type' 
                        && key != 'car_no' 
                        && key != 'shipper_agent' 
                        && key != 'shipper_phone' 
                        && key != 'dept_id' 
                        && key != 'service_type' 
                        && key != 'contract_id' 
                        && key != 'customer_handler' 
                        && key != 'shipping_address' 
                        && key != 'shipping_tel'
                        && key != 'car_type'
                        && key != 'is_nobody'
                        && key != 'pdf_url') {
                    return false;
                }
            }
        }
        return true;
    }
    // 判断数组中的值不为空
    const areAllValuesDefined = (arr) =>{
        if(itemData.value.transport_type == 1){
            return arr.every((item)=> {
                return item.goods_id !== '' && item.ticket_number !== '' && item.box !== '' && item.is_empty !== '' && item.box_type !== '' && item.box_belong !== '' && item.number_yu !== '' && item.hz_weight !== '' && item.bz_weight !== '' && item.cyr_weight !== '' && item.jf_weight !== '';
            });
        }else{
            return arr.every((item)=> {
                return item.goods_id !== '' && item.ticket_number !== '' && item.number_yu !== '' && item.hz_weight !== '' && item.bz_weight !== '' && item.cyr_weight !== '' && item.jf_weight !== '';
            });
        }
    }

    const tagList = ref([])
const getTagList = () => {
    request({
      url:'system/tag/index',
      method: 'get',
      params:{
        openPage:false
      },
    }).then(res=>{
      tagList.value = res.data.items
    })
}
    const addItem = ref({
    type:1,
    customer_type:1,
    status:1,
    name:'',
    leader:'',
    phone:'',
    e_mail:'',
    card_id:'',
    file:'',
    tag_ids:[],
    remark:'',
    // 工商信息
    company_data:{
      companyName:'',  // 公司名称
      companyType:'',  // 公司类型
      legalPerson:'',  // 法定代表人
      legalPersonType:'',  //  法人类型
      phoneNumber:'',   // 电话号码
      phoneNumber_note:'',   // 电话备注
      capital:'',       // 注册资本
      realCapital:'',   // 实收注册资金
      companyCode:'',  // 注册码
      creditNo:'',  // 企业信用代码
      orgCode:'',   // 组织机构代码
      businessScope:'',  // 经营范围
      authority:'',  // 登记机关
      companyStatus:'',   // 经营状态
      establishDate:'',  // 成立时间
      operationStartdate:'',  // 营业期限开始时间
      operationEnddate:'',  // 营业期限结束时间
      issueDate:'',  // 核准日期
      province:'',  // 省份
      provinceCode:'',   // 省份行政区号
      city:'',   // 地市
      cityCode:'',  // 地市行政区号
      district:'', // 地区
      districtCode:'',  // 地区行政区号
      companyAddress:'',  // 注册地址
      industry:'',  // 行业
      historyNames:'', // 曾用名
      lastUpdatedTime:'',  // 更新时间
      companyStatus:'',  // 登记状态
      email:'',   // 邮箱
      email_note:'',  // 邮箱备注
      address:'',  // 地址
      address_note:'',   // 地址备注
      website:'',  // 网址
      website_note:'', // 网址备注
    },
    


    // 银行信息
    opening_bank:'', // 开户行
    account:'', // 收款账户
    account_name:'', // 开户名称
  })
  const typeList = ref([
    {label:'园区企业',value:1},
    {label:'用户企业',value:2},
  ])
  const customerTypeList = ref([
    {label:'企业',value:1},
  ])
  const statusList= ref([
    {label:'正常',value:1},
    {label:'停用',value:2},
  ])
  const visible_Add = ref(false)
  const handleType = (e)=>{
    console.log(e)
    if(e == 1){
      customerTypeList.value = [
        {label:'企业',value:1},
      ]
      addItem.customer_type.value = 1
    }else{
      customerTypeList.value = [
        {label:'企业',value:1},
        {label:'个人',value:2},
      ]
      addItem.customer_type.value = 1
    }
  }
  const openAdd = () => {
    addItem.value = {
        type:1,
        customer_type:1,
        status:1,
        name:'',
        leader:'',
        phone:'',
        e_mail:'',
        card_id:'',
        file:'',
        tag_ids:[],
        remark:'',
        company_data:{
          companyName:'',  // 公司名称
          companyType:'',  // 公司类型
          legalPerson:'',  // 法定代表人
          legalPersonType:'',  //  法人类型
          phoneNumber:'',   // 电话号码
          phoneNumber_note:'',   // 电话备注
          capital:'',       // 注册资本
          realCapital:'',   // 实收注册资金
          companyCode:'',  // 注册码
          creditNo:'',  // 企业信用代码
          orgCode:'',   // 组织机构代码
          businessScope:'',  // 经营范围
          authority:'',  // 登记机关
          companyStatus:'',   // 经营状态
          establishDate:'',  // 成立时间
          operationStartdate:'',  // 营业期限开始时间
          operationEnddate:'',  // 营业期限结束时间
          issueDate:'',  // 核准日期
          province:'',  // 省份
          provinceCode:'',   // 省份行政区号
          city:'',   // 地市
          cityCode:'',  // 地市行政区号
          district:'', // 地区
          districtCode:'',  // 地区行政区号
          companyAddress:'',  // 注册地址
          industry:'',  // 行业
          historyNames:'', // 曾用名
          lastUpdatedTime:'',  // 更新时间
          companyStatus:'',  // 登记状态
          email:'',   // 邮箱
          email_note:'',  // 邮箱备注
          address:'',  // 地址
          address_note:'',   // 地址备注
          website:'',  // 网址
          website_note:'', // 网址备注
        },
        
        opening_bank:'', // 开户行
        account:'', // 收款账户
        account_name:'', // 开户名称
      }
      customerTypeList.value = [
        {label:'企业',value:1},
      ]
      visible_Add.value = true
  }
  
  const handleAddOk = async ()=>{
    let res = await dept.save(addItem.value)
    if(res.code == 200){
        Message.success('添加成功')
        setTimeout(function(){
            handleDeptList()
        },500)
        return true
    }else{
        Message.error(res.message)
        return false
    }
        
  }



</script>
<style lang="less" scoped>
.jcBox{
    width: calc((100% - 24px) / 2);
    margin-right: 12px;
    margin-bottom: 8px;
    &:nth-child(2n){
        margin-right: 0px;
    }
}
.scllBox{
    overflow:auto;
    -ms-overflow-style: none;  /* IE 10+ */
    scrollbar-width: none;  /* Firefox */
    .scllItem{
        margin-bottom: 12px;
        &:last-child{
            margin-bottom: 0px;
        }
    }
}

.scllBox::-webkit-scrollbar {
  display: none;
}

</style>
<script>
export default { name: "prediction:onepipei" };
</script>
<style scoped>
    .contenBox{
      height:500px;
      padding:12px;
    }
    .contenBox::-webkit-scrollbar{
      display: none;
    }
    .marbot24{
        margin-bottom: 12px;
    }
</style>